//==========================================================================//
//                                                                          //
//  PACHUBE Demo Sketch         Version 0.1                     March 2012  //
//                                                                          //
//  Written for the Arduino Duemilanove w/ ATmega328                        //
//                                                                          //
//  PACHUBE Arduino Library Demo Sketch                                     // 
//                                                                          //
//  Created by JFLagarde (jeanfrancoislagarde@hotmail.com)                  //
//                                                                          //
//  This file is part of OpenWS (http://code.google.com/p/openws/)          //
//                                                                          //
//==========================================================================//
//                                                                          //
//  Notes:                                                                  //
//                                                                          //
//                                                                          //
//==========================================================================//
//                                                                          //
//  Copyright 2012 Jean-Francois Lagarde (jeanfrancoislagarde@hotmail.com)  //
//  This program is distributed under the terms of                          //
//  the GNU General Public License                                          //
//                                                                          //
//  This program is free software: you can redistribute it and/or modify    //
//  it under the terms of the GNU General Public License as published by    //
//  the Free Software Foundation, either version 3 of the License, or       //
//  (at your option) any later version.                                     //
//                                                                          //
//  This program is distributed in the hope that it will be useful,         //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//  GNU General Public License for more details.                            //
//                                                                          //
//  You should have received a copy of the GNU General Public License       //
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                          //
//==========================================================================//
#include <Ethernet.h>
#include <SPI.h>
#include <PACHUBE.h>

byte mac[]     = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[]      = {192,168,1,54};   // IP address of Ethernet Shield

// Setup a PACHUBE instance
PACHUBE myPACHUBE = PACHUBE();

void setup(void) { 
	// start serial port
	Serial.begin(9600);
	Serial.println("PACHUBE Library Demo");
	analogReference(EXTERNAL);
	
	Ethernet.begin(mac);
    delay(1000);   // give the Ethernet shield a second to initialize
  
    // start the Ethernet connection:
    if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      Ethernet.begin(mac, ip); // Configure manually
    }
	
	myPACHUBE.init();
}

void loop(void) { 
	int value0 = analogRead(0);
	int value1 = analogRead(1);
	
	myPACHUBE.send(value0,value1);

	Serial.print(value0);
	Serial.print(", ");
	Serial.print(value1);
	Serial.println();
	
	delay(3000);
}